Skip to content

fix(stack): surface fetch_old_pr_heads failures instead of swallowing#1315

Merged
mergify[bot] merged 2 commits intomainfrom
devs/jd/fix/stack-revision-history-fetch-resilience/surface-fetch-old-pr-heads-failures-instead--d33459ea
Apr 30, 2026
Merged

fix(stack): surface fetch_old_pr_heads failures instead of swallowing#1315
mergify[bot] merged 2 commits intomainfrom
devs/jd/fix/stack-revision-history-fetch-resilience/surface-fetch-old-pr-heads-failures-instead--d33459ea

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented Apr 29, 2026

The exception handler around fetch_old_pr_heads previously did a
silent pass, leaving every revision-history entry stamped
"unknown" with no clue why. When a real failure happens (fork remote
without refs/pull/N/head, network error, missing permissions, …)
the user has no signal that anything went wrong — they only see the
symptom in the PR comment days later.

Log the underlying error in orange so the cause is visible at push
time. The exception text is run through rich.markup.escape so any
[/] in the git error message is rendered literally rather than
parsed as Rich markup. Behaviour stays non-fatal: classification
still falls back to "unknown" and the push proceeds.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Depends-On: #1316

@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 29, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 fix(utils): decode CommandError stdout safely so str never raises #1316
2 fix(stack): surface fetch_old_pr_heads failures instead of swallowing #1315 👈

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 29, 2026 10:13 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 29, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 ⛓️ Depends-On Requirements

Wonderful, this rule succeeded.

Requirement based on the presence of Depends-On in the body of the pull request

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@mergify mergify Bot requested a review from a team April 29, 2026 10:20
@jd jd changed the base branch from devs/jd/fix/stack-revision-history-fetch-resilience/anchor-old-pr-head-shas-local-refs-revision--e5aebff2 to main April 29, 2026 11:08
@jd jd force-pushed the devs/jd/fix/stack-revision-history-fetch-resilience/surface-fetch-old-pr-heads-failures-instead--d33459ea branch from c36d11f to cdaab37 Compare April 29, 2026 11:08
@jd
Copy link
Copy Markdown
Member Author

jd commented Apr 29, 2026

Revision history

# Type Changes Reason Date
1 initial c36d11f 2026-04-29 11:08 UTC
2 rebase c36d11f → cdaab37 2026-04-29 11:08 UTC
3 content cdaab37 → 525f374 2026-04-29 12:22 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections April 29, 2026 11:09 Failure
@jd jd marked this pull request as ready for review April 29, 2026 11:09
Copilot AI review requested due to automatic review settings April 29, 2026 11:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes stack push surface failures from fetch_old_pr_heads (used for revision-history change-type detection) instead of silently swallowing them, while keeping the behavior non-fatal.

Changes:

  • Capture utils.CommandError from fetch_old_pr_heads and log the underlying failure.
  • Keep revision-history classification behavior unchanged (fallback remains "unknown" on fetch failure).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mergify_cli/stack/push.py
jd and others added 2 commits April 29, 2026 14:22
`CommandError.__str__` decoded captured stdout as strict UTF-8, so any
non-UTF-8 bytes from a subprocess (legacy locales, binary diff fragments,
truncated multi-byte sequences) would turn `str(error)` into a
`UnicodeDecodeError`. Every error-formatting site is affected — the
top-level CLI handler in `cli.py:104`, log messages, etc. — converting
the failure into an unhandled traceback instead of a clean message.

Switch to `decode(errors="replace")`. Invalid bytes become the U+FFFD
replacement character; all other formatting is preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I3e3fd853218a6c4294b17e9529794320288124e5
The exception handler around `fetch_old_pr_heads` previously did a
silent `pass`, leaving every revision-history entry stamped
"unknown" with no clue why. When a real failure happens (fork remote
without `refs/pull/N/head`, network error, missing permissions, …)
the user has no signal that anything went wrong — they only see the
symptom in the PR comment days later.

Log the underlying error in orange so the cause is visible at push
time. The exception text is run through `rich.markup.escape` so any
`[`/`]` in the git error message is rendered literally rather than
parsed as Rich markup. Behaviour stays non-fatal: classification
still falls back to "unknown" and the push proceeds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: Id33459ea069be228f73fb02a7f813f16db145b71
@jd jd force-pushed the devs/jd/fix/stack-revision-history-fetch-resilience/surface-fetch-old-pr-heads-failures-instead--d33459ea branch from cdaab37 to 525f374 Compare April 29, 2026 12:22
@jd jd changed the base branch from main to devs/jd/fix/stack-revision-history-fetch-resilience/decode-commanderror-stdout-safely-str-never-raises--3e3fd853 April 29, 2026 12:22
@mergify mergify Bot deployed to Mergify Merge Protections April 29, 2026 12:22 Active
Base automatically changed from devs/jd/fix/stack-revision-history-fetch-resilience/decode-commanderror-stdout-safely-str-never-raises--3e3fd853 to main April 29, 2026 17:14
@mergify mergify Bot requested a review from a team April 29, 2026 18:09
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 30, 2026

Merge Queue Status

This pull request spent 8 minutes 11 seconds in the queue, including 7 minutes 52 seconds running CI.

Required conditions to merge

mergify Bot added a commit that referenced this pull request Apr 30, 2026
@mergify mergify Bot added the queued label Apr 30, 2026
@mergify mergify Bot merged commit f6a87c8 into main Apr 30, 2026
12 checks passed
@mergify mergify Bot deleted the devs/jd/fix/stack-revision-history-fetch-resilience/surface-fetch-old-pr-heads-failures-instead--d33459ea branch April 30, 2026 06:52
@mergify mergify Bot removed the queued label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants